package de.upb.messerschmidt.set.entity;

import java.util.ArrayList;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import de.upb.messerschmidt.set.GetPublicationServlet;

/**
 * A Person is the user itself. All the user-data stored will be received from
 * Mendeley (via OAuth) and submitted from the Android application. Other than
 * that a List of {@link EventStatus} and a List of {@link Contact}s (as Key)
 * gets stored.
 * 
 * The secret and the token will be used by the {@link GetPublicationServlet} to
 * return a user's publications.
 * 
 * @author Tim Messerschmidt
 * 
 */

@PersistenceCapable(detachable = "true")
public class Person {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	@Persistent
	private String name;
	@Persistent
	private String prename;
	@Persistent
	private String company;
	@Persistent
	private String email;
	@Persistent
	private String token;
	@Persistent
	private String secret;
	@Persistent(mappedBy = "person")
	@Element(dependent = "true")
	private ArrayList<EventStatus> events = new ArrayList<EventStatus>();
	@Persistent
	private ArrayList<Key> contacts = new ArrayList<Key>();

	/**
	 * @param name
	 *            the Person's name
	 * @param prename
	 *            the Person's prename
	 * @param company
	 *            the Person's company
	 * @param accounts
	 *            a list of the Person's various accounts
	 * @param events
	 *            a list of the Person's events
	 */
	public Person(String name, String prename, String company, String email,
			String token, String secret) {
		this.name = name;
		this.prename = prename;
		this.company = company;
		this.email = email;
		this.token = token;
		this.secret = secret;
	}

	/**
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the prename
	 */
	public String getPrename() {
		return prename;
	}

	/**
	 * @return the company
	 */
	public String getCompany() {
		return company;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @return the token
	 */
	public String getToken() {
		return token;
	}

	/**
	 * @return the secret
	 */
	public String getSecret() {
		return secret;
	}

	/**
	 * @return the events
	 */
	public ArrayList<EventStatus> getEvents() {
		return events;
	}

	/**
	 * @return the contacts
	 */
	public ArrayList<Key> getContacts() {
		return contacts;
	}

	/**
	 * @param key
	 *            the key to set
	 */
	public void setKey(Key key) {
		this.key = key;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param prename
	 *            the prename to set
	 */
	public void setPrename(String prename) {
		this.prename = prename;
	}

	/**
	 * @param company
	 *            the company to set
	 */
	public void setCompany(String company) {
		this.company = company;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @param token
	 *            the token to set
	 */
	public void setToken(String token) {
		this.token = token;
	}

	/**
	 * @param secret
	 *            the secret to set
	 */
	public void setSecret(String secret) {
		this.secret = secret;
	}

	/**
	 * @param events
	 *            the events to set
	 */
	public void setEvents(ArrayList<EventStatus> events) {
		this.events = events;
	}

	/**
	 * @param contacts
	 *            the contacts to set
	 */
	public void setContacts(ArrayList<Key> contacts) {
		this.contacts = contacts;
	}
}
